#include <bits/stdc++.h>
using namespace std;

// is n! divided by a^b?
bool is_divide(long long n, long long a, long long b) {
    long long p = 2;
    while (a > 1) {
       if (p * p > a) {
           p = a;
       }
       if (a % p == 0) {
           long long cnt_in_a = 1;
           a /= p;
           while (a % p == 0) {
               cnt_in_a++;
               a /= p;
           }
           cnt_in_a *= b;
           long long cnt_in_fac = 0;
           long long d = p;
           while (n >= d) {
              cnt_in_fac += n / d;
              d *= p;
           }
           if (cnt_in_fac < cnt_in_a) {
               return false;
           }
       }
       ++p;
    }
    return true;
}

int main() {
  int t;
  for(cin >> t; t > 0; -- t) {
      long long n, a, b;
      cin >> n >> a >> b;
      cout << (is_divide(n, a, b) ? "Yes\n" : "No\n");
  }
}
